package LeetcodeTest_thirty_nine;
//1207.独一无二的出现次数

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

public class uniqueOccurrences
{
    public static void main(String[] args)
    {
        int[] arr={1,2,2,1,1,3};
        System.out.println(solution.uniqueOccurrences(arr));
    }
}
class solution
{
    public static boolean uniqueOccurrences(int[] arr)
    {
        HashMap<Integer,Integer> num=new HashMap<>();
        ArrayList<Integer> count=new ArrayList<>();
        for(int i=0;i<arr.length;i++)
        {
            if(num.get(arr[i])==null)
                num.put(arr[i],1);
            else
            {
                int value=num.get(arr[i]);
                num.put(arr[i],value+1);
            }
        }
        Set<Integer> integers = num.keySet();
        for(Integer key:integers)
        {
            if(!count.contains(num.get(key)))
                count.add(num.get(key));
            else
                return false;
        }
        return true;
    }
}